<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--顶部bar组件-->
<div id="top" th:fragment="topBar">
    <p id="user_info" th:text="${session.get('用户信息')}">

    </p>
</div>
<!--侧边栏组件-->
<div id="nav" th:fragment="navBar" class="floatDiv">
    <table>
        <tr>
            <td>
                <!--  注意值传递有可能取不到，这里就用每个页面传递状态 -->
                <a th:href="@{/page/home.html}" th:class="(${status} == 'home') ?'checkA':'check'">主页</a>
            </td>
        </tr>
        <tr>
            <td>
                <a th:href="@{/jump/page/person.html}"
                   th:class="(${status} == 'user') ?'checkA':'check'">个人信息</a>
            </td>
        </tr>
        <tr>
            <td>
                <a th:href="@{/employ/list}" th:class="(${status} == 'employ') ?'checkA':'check'">员工管理</a>
            </td>
        </tr>

    </table>
</div>
<!--员工信息表组件-->
<div class="floatDiv" id="dataDiv" th:fragment="employInfotable">
    <table>
        <caption><span><strong>员工信息表</strong></span></caption>
        <tr id="employTr">
            <td>ID</td>
            <td>Last_name</td>
            <td>Email</td>
            <td>Gander</td>
            <td>Department</td>
            <td>Birth</td>
            <td>删除</td>
            <td>编辑</td>
        </tr>
        <tr th:each="employ,stat:${employ_list_info}">
            <td th:text="${employ.getId()}"></td>
            <td th:text="${employ.getName()}"></td>
            <td th:text="${employ.getEmail()}"></td>
            <td th:text="(${employ.getGender()} == 1) ? '男':'女'"></td>
            <td th:text="${employ.getDepartment().getDepartmentName()}"></td>
            <td th:text="${#dates.format(employ.getBirth(),'yyyy/MM/dd')}"></td>
            <td>
                <a th:href="@{/employ/delete/}+${stat.index}">
                    <button></button>
                </a>

            </td>
            <td>
                <a th:href="@{/employ/modify/}+${stat.index}">
                    <button></button>
                </a>

            </td>
        </tr>
    </table>
    <p id="inputP">
        <input type="button" value="添加员工" onclick="jump()">
        <input type="button" value="上一页" onclick="up()">
        <span id="inputSpan" th:text="${Current_Page}"></span>
        <span id="inputSpan">/</span>
        <span id="inputSpan" th:text="${total_page}"></span>
        <input type="button" value="下一页" onclick="next()">
    </p>
</div>
<!--添加员工组件-->
<form th:action="@{/employ/add}" method="post" th:fragment="addFrom">
    <!--  隐藏域 存放修改的id方便修改-->
    <input type="hidden" name="id" th:value="(${employ_info} != null) ?  ${employ_info.id} : null"/>
    <!-- 名字 -->
    <input type="text" name="name" placeholder="输入名字"
           th:value="(${employ_info} != null) ?  ${employ_info.name} : null"/>
    <br/>
    <!-- 邮件 -->
    <input type="email" name="email" placeholder="输入邮件"
           th:value="(${employ_info != null }) ?  ${employ_info.email} : null"/>
    <br/>
    <!-- 性别 -->
    <input type="radio" name="gender" value="1" th:checked="${employ_info != null} ?  (${employ_info.gender == 1} ? 'checkd':null): null"/> 男
    <input type="radio" name="gender" value="0" th:checked="${employ_info != null} ?  (${employ_info.gender == 0} ? 'checkd':null): null"/> 女
    <br/>
    <!-- 部门 -->
    <select name="department.departmentName">
        <option th:selected="${employ_info == null}">选择员工</option>
        <!--      跳转到此页面应该携带一个参数就是这个部门信息，为了省时间就自动加上去了  value是他的名字-->
        <option th:selected="${employ_info != null} ?  (${employ_info.department.departmentName == '运营部'} ? 'selected':null): null">运营部</option>
        <option th:selected="${employ_info != null} ?  (${employ_info.department.departmentName == '行政部'} ? 'selected':null): null">行政部</option>
        <option th:selected="${employ_info != null} ?  (${employ_info.department.departmentName == '财务部'} ? 'selected':null): null">财务部</option>
        <option th:selected="${employ_info != null} ?  (${employ_info.department.departmentName == '质量管理部'} ? 'selected':null): null">质量管理部</option>
    </select>
    <br/>
    <!-- 生日 -->
    <input type="text" name="birth" placeholder="输入日期" th:value="${employ_info != null} ? ${#dates.format(employ_info.birth,'yyyy-MM-dd')}:null  "/>
    <br/>
    <input type="submit" th:value="(${employ_info} != null) ? '修改':'提交'"/>
</form>
</body>
</html>